package chapter_twentyFour.text354;

/**
 * Data time:2021/11/22 16:07
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class MovieTicket {
    private Double price;
    private Discount discount;  //维持一个对抽象折扣类的引用

    public void setPrice(Double price) {
        this.price = price;
    }

    //注入一个折扣类对象
    public void setDiscount(Discount discount) {
        this.discount = discount;
    }

    public Double getPrice() {
        //调用折扣类的折扣价计算方法
        return discount.calculate(this.price);
    }
}
